<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>窗口一</title>
</head>

<body>
    <button id="btn1">打开窗口2</button>
    <script>
        const channel = new BroadcastChannel('tab-communication');
        // 接收消息
        channel.onmessage = (event) => {
            console.log('收到广播消息:', event.data);
            // 处理消息...
        };
        const btndom = document.querySelector("#btn1");
        btndom.addEventListener("click", () => {
            console.log("ccccc测试")
        });
    </script>
</body>

</html>